version: "3.7"

networks:
  postgres-network:
    driver: bridge
    ipam:
      config:
        - subnet: ${POSTGRES_SUBNET}

services:
  postgres:
    container_name: postgres
    build:
      context: ./postgres
      dockerfile: Dockerfile
    working_dir: /var/lib/postgres
    restart: unless-stopped
    ports:
      - "5432:5432"
    volumes:
      - ${POSTGRES_STORAGE_PATH}:/var/lib/postgresql/data
      - ${POSTGRES_LOG_PATH}:/var/log/postgresql
    networks:
      postgres-network:
        ipv4_address: ${POSTGRES_IP}
    environment:
      - POSTGRES_USER=postgres
      - POSTGRES_PASSWORD=postgres
